﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<Hotnet.Entity.Video>" %>

<%@ Import Namespace="Hotnet.Web.MVCExtension" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=ViewData["Title"] %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div>
		<div style="font-size: x-large">
			<%=ViewData["Title"] %></div>
		<div style="margin: 15px 0px 3px 2px;">
			<span style="color: Red">所在位置: </span><a href="/AdminVideo/Index/?categoryID=<%=ViewData["CategoryID"] %>"
				style="text-decoration: none;">
				<%=ViewData["CategoryName"] %>
			</a>->
			<%=ViewData["Title"] %>
		</div>
	</div>
	<div style="text-align: center; color: Red; font-size: large">
		<%=TempData["UpdateResult"]%></div>
	<% using (Html.BeginForm("Create", "AdminVideo", null, FormMethod.Post, new { enctype = "multipart/form-data", id = "formCreateUpdate" }))
	{%>
	<input type="hidden" id="hiddenCategoryID" name="CategoryID" value="<%=ViewData["CategoryID"] %>" />
	<table width="100%" class="ma list">
		<tr>
			<td align="right" style="width: 13%">
				<label for="Name">
					视频名称:</label>
			</td>
			<td style="width: 40%">
				<%= Html.TextBox("Name")%>
			</td>
			<td align="right" style="width: 13%">
				<label for="VideoSrc">
					视频播放地址:</label>
			</td>
			<td>
				<%= Html.TextBox("VideoSrc")%>
				<a href="javascript:void(0)" onclick="preview()">预览</a>
			</td>
		</tr>
		<tr>
			
			<td align="right">
				视频Tag:
			</td>
			<td>
				<%= Html.TextBox("Tags")%>
			</td>
			<td align="right">
				<label for="SourceFromID">
					来源网站:</label>
			</td>
			<td>
				<input type="hidden" name="SourceFromID" id="SourceFromID" />
				<%Html.RenderPartial("SelectControl", ViewData["SourceFrom"]); %>
				<span id="SpanSourceFromID"></span>
			</td>
		</tr>
		<%--<tr>
			<td align="right">
				<label for="DefineType">
					设定归属列表:</label>
			</td>
			<td>
				<%=Html.DropDownList("DefineType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumDefineType>("设定归属列表..", Convert.ToString((int)EnumDefineType.None)), new { style="width:280" })%>
			</td>
		</tr>--%>
		<tr>
			<td align="right">
				<label for="CoverImagePath">
					封面图片:</label>
			</td>
			<td>
				<input type="file" onchange="showPreviewImage();" id="CoverImage" style=" width:270px;" name="coverImage" />
			</td>
			<td colspan="2">
				<img src='<%=Model==null?"#":Model.CoverImagePath %>' id="coverImg" style="height:200px;" />
			</td>
		</tr>
	</table>
	<a href="javascript:showMore()" id="aShowMore" style=" padding:5px;">更多信息</a>
	<div id="divMore" style="display: none; border:1px dotted #70828f;">
		<table width="100%" class="ma list">
			<tr>
				<td align="right" style="width: 13%">
					<label for="Director">
						导演:</label>
				</td>
				<td style="width: 40%">
					<input type="hidden" name="Director" id="Director" />
					<%Html.RenderPartial("SelectControl", ViewData["Director"]); %>
					<span id="SpanDirector"></span>
				</td>
				<td align="right" style="width: 13%">
					<label for="DownLoadUrl">
						主角:</label>
				</td>
				<td>
					<input type="hidden" name="CastCharacters" id="CastCharacters" />
					<%Html.RenderPartial("SelectControl", ViewData["Star"]); %>
					<span id="SpanCastCharacters"></span>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label for="previewYear">
						上映时间:</label>
				</td>
				<td>
					<%=Html.DropDownList("previewYear", Hotnet.Web.Controllers.Admin.AdminVideoController.PreviewTimeList, new { style = "width:120px;" })%>
				</td>
				<td align="right">
					<label for="IsCanPlayInner">
						是否内部播放:</label>
				</td>
				<td>
					<%=Html.CheckBoxRadioGroup("IsCanPlayInner", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumIsCanPlayInner>(), new List<string>() { Model == null ? Convert.ToString((int)EnumIsCanPlayInner.是) : (Model.IsCanPlayInner.Value ? Convert.ToString((int)EnumIsCanPlayInner.是) : Convert.ToString((int)EnumIsCanPlayInner.否)) }, 2, null, "50px", HtmlControlType.radio)%>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label for="Zone">
						地区:</label>
				</td>
				<td>
					<%=Html.DropDownList("Zone", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumZone>("选择地区..", ""), new { style = "width:120px;" })%>
				</td>
				<td align="right">
					<label for="IsDVD">
						是否高清:</label>
				</td>
				<td>
					<%=Html.CheckBoxRadioGroup("IsDVD", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumIsDVD>(), new List<string>() { Model==null?Convert.ToString((int)EnumIsDVD.否):(Model.IsDVD.Value?Convert.ToString((int)EnumIsDVD.是):Convert.ToString((int)EnumIsDVD.否)) }, 2, null, "50px;", HtmlControlType.radio)%>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label for="DownLoadUrl">
						视频下载地址:</label>
				</td>
				<td colspan="3">
					<%= Html.TextBox("DownLoadUrl")%>
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<label for="Description" style=" margin-left:18px;">
						视频描述:</label>
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<%= Html.TextArea("Description")%>
				</td>
			</tr>
		</table>
	</div>
	<table width="100%" class="ma list">
		<tr>
			<td align="center">
				<input type="submit" value="确定" />
				<input type="button" value="返回" onclick="window.location.href='/AdminVideo/Index/?categoryID=<%=ViewData["CategoryID"] %>'" />
			</td>
		</tr>
	</table>
	<% } %>
	<div id="flashPreview" style="display: none;">
	</div>

	<script type="text/javascript">
		var oFCKeditor = new FCKeditor('Description', "100%", "250");
		oFCKeditor.ReplaceTextarea();

		var categoryId = '<%=Model==null?ViewData["CategoryID"]:Model.CategoryID %>';
		var videoId = '<%=Model==null?0:Model.VideoID %>';
		var flashBoxy;
		var flashCodePart1 = "<embed src='";
		var flashCodePart2 = "' id='flashEmbed'"
							+ "'quality='high' width='480' height='400' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash'>'"
							+ "</embed>";

		function setSourceFrom(result) {

			$("#SpanSourceFromID").html("");
			if (result == null || result.length == 0) {
				$("#SourceFromID").attr("value", "");
				return;
			}
			$("#SpanSourceFromID").html(result[0].Text);
			$("#SourceFromID").attr("value", result[0].Value);
		}

		function setStar(result) {
			$("#SpanCastCharacters").html("");
			if (result.length == 0)
				return;
			var str = "";
			var strValue = "";
			for (var i = 0; i < result.length; i++) {
				str += result[i].Text + " "
				strValue += result[i].Value + ","
			}
			$("#SpanCastCharacters").html(str);
			$("#CastCharacters").attr("value", strValue);

		}

		function setDirector(result) {

			$("#SpanDirector").html("");
			if (result.length == 0)
				return;
			$("#SpanDirector").html(result[0].Text);
			$("#Director").attr("value", result[0].Value);
		}

		function preview() {
			var flashCode = flashCodePart1 + $("#VideoSrc").val() + flashCodePart2;
			$("#flashPreview").html(flashCode);
			if (flashBoxy == null)
				flashBoxy = new Boxy($('#flashPreview'), { modal: false, title: '视频预览', closeText: '[×]', draggable: true });
			else
				flashBoxy.show();
		}

		function showPreviewImage() {
			$('#coverImg').attr('src', $('#CoverImage').val())
			$('#coverImg').attr('style', "width:200px;height:150px;");
		}

		$(document).ready(
			function() {

				$("#Name").attr("style", "width:270px;");
				$("#Tags").attr("style", "width:270px;");
				sc_calculateResult(2, setStar, 'checkbox');
				sc_calculateResult(1, setSourceFrom, 'radio');
				sc_calculateResult(3, setDirector, 'radio');

				if (videoId != 0) {
					$("#formCreateUpdate").attr("action", "/AdminVideo/Edit/" + videoId);
					$("#hiddenCategoryID").attr("value", categoryId);
				}
				var childers = document.getElementById("DefineType").getElementsByTagName("option");
				document.getElementById("DefineType").removeChild(childers[childers.length - 1]);
				$("#VideoSrc").blur(
					function() {
						var likeSource = getSourceFromID("window1", $("#VideoSrc").val());
						setSourceFrom(likeSource);
					}
				);
			}
		);

			function showMore() {
				if ($("#aShowMore").html() == "更多信息") {
					$("#divMore").show("slow");
					$("#aShowMore").html("隐藏信息");
				}
				else {
					$("#divMore").hide("slow");
					$("#aShowMore").html("更多信息");
				}
			}
		
	</script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
</asp:Content>
